function valord = ApprInt(val)
%ApprInt - approximate integer value
%
%       Valord = ApprInt(Val)
%
% Let Val be a number ed n be its order of magnitude. The output Valord is
%   - 10^n if 10^n <= abs(val) < 2*10^n;
%   - 3*10^n if 2*10^n <= abs(val) < 4*10^n;
%   - 5*10^n if 4*10^n <= abs(val) < 6*10^n;
%   - 7*10^n if 6*10^n <= abs(val) < 8*10^n;
%   - 10^(n+1) if abs(val) >= 8*10^n.

% G. Teza, 2022 

aval = abs(val);

% order of magnitude:
n = floor(log(aval)./log(10));
% value of the order of magnitude:
valapp = 10.^n;

I3 = (aval./valapp >= 3)&(aval./valapp < 4);
I5 = (aval./valapp >= 4)&(aval./valapp < 6);
I7 = (aval./valapp >= 6)&(aval./valapp < 8);
I10 = aval./valapp >= 8;
valord = valapp;
valord(I3) = 3*valapp(I3);
valord(I5) = 5*valapp(I5);
valord(I7) = 7*valapp(I7);
valord(I10) = 10*valapp(I10);